<?php
defined('DCS_ROOT') or exit(header("HTTP/1.1 430 Not Forbidden"));

class uploads {
	function defaultAction(){
		$url = getUrl();
		$type = $url['params']['1'];
		$cid = $url['params']['2'];
		if(!empty($_FILES['Filedata']['name'])){			
			require_once(CLASS_PATH."class/upload.class.php" );
			$upload = new Upload();
			$upload->config(array(
				'targetDir' => '/',
				'saveType' => 2
			));
			$files = $upload->saveFiles('Filedata');
			$file_url = $files['0']['filenames'];
		}else{
			exit(0);
		}		
		$sourFile = UPLOAD.$file_url;
		$targetFile = UPLOAD.'thumb/'.$file_url;
		makeThumbImage($sourFile,$targetFile);
		$DB  = getDB();
		$sql = "INSERT INTO upload (type,cid,filepath) VALUES ('$type','$cid','$file_url')";
		$DB->query($sql);
		echo "FILEID:".$file_url;
	}

}
?>